let idNum: number = 1
export interface AddScoreOpt {
  // x坐标
  x: number
  // y坐标
  y: number
  // 图片
  img: any
}
export default class AddScore {
  private w: number = 40
  private h: number = 40
  private x: number
  private y: number
  private img: any
  private id: number
  private v: number = 0
  private type: string = 'AddScore'
  private isDestory: boolean = false

  constructor(opt: AddScoreOpt) {
    this.id = idNum += 1
    this.x = opt.x || 20
    this.y = opt.y || 20
    this.img = opt.img
  }

  // 更新数据
  updata() {
    this.y = this.y - this.getStep()
    this.x = this.x + this.getStep()
    this.w -= 1
    this.h -= 1
    this.isDestory = this.v > 8
  }

  getStep(): number {
    return (this.v += 0.1)
  }

  destory() {
    this.img = null
  }
}
